package org.spp.voronoi;

import java.util.ArrayList;
import java.util.List;
import org.spp.utilities.SetUtils;

/**
 * Vertex2D.java
 * @author Ilio Catallo, Eleonora Ciceri
 * @version 1.0
 * @see Vertex
 * 
 * Description: class that implements a vertex of the voronoi diagram in case of
 *              bidimensional vector spaces.
 * 
 * Date: Jul 10, 2011
 */
public class Vertex2D extends Vertex{
        
    /**
     * Constructor for the class Vertex2D
     * @param coordinates 
     */
    Vertex2D(double[] coordinates) {
        super(coordinates);
    }
    
    /**
     * Constructor for the class Vertex3D
     * @param coordinates 
     */
    public Vertex2D (double[][] coordinates) {
        super(coordinates);
    } 
    
    @Override
    public void computeEdges(){
        
        if (edges.isEmpty()){
            
            for (int j = 0; j < cells.size(); j++){
                
                List<Facet> vertexFacets = cells.get(j).findVertexFacets(this);
                
                for (int k = 0; k < vertexFacets.size(); k++){
                    
                    List<Facet> edgeFacets = new ArrayList<Facet>();
                    edgeFacets.add(vertexFacets.get(k));
                    edges.add(new Edge2D(this, null, cells.get(j).getCentroid(), edgeFacets));
                }
                
            } 
        }
        
        this.edges = SetUtils.findDistincts(this.edges);
        
    }
      
}
